<%@ include file="/common/taglibs.jsp"%>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevent caching at the proxy server
%>

<head>
    <title><fmt:message key="busquedapremiosForm.title"/></title>
    <meta name="heading" content="<fmt:message key='busquedapremiosForm.heading'/>"/>
</head>

<form:form id="busquedapreciosForm">

	<fieldset style="width: 300px">
	<legend><fmt:message key="common.filtros.busqueda"/></legend>
		
		<br/><div>
			<fmt:message key="common.catalogo"/><br/>
	        <select class="text mediumlarge" id="cmbCatalogo_id" >
	        	<c:forEach var="bncatalogo" items="${catalogos}">
	        		<option value="${bncatalogo.id}">
	        			${bncatalogo.deCatalogo}
	        		</option>
	        	</c:forEach>
	       	</select>
		</div><br/>
		
		<div>
			<fmt:message key="common.categoria"/><br/>
			<select class="text mediumlarge" id="cmbCategoria_id">
				<option value="-1">
					<fmt:message key="label.itemdefault"/>
				</option>
				<c:forEach var="categoria" items="${categorias}">	
					<option value="${categoria.id}">
						${categoria.deCategoria}
					</option>
				</c:forEach>			
			</select>
		</div><br/>
		
		<div>
			<fmt:message key="common.premio"/><br/>
			<input id="txtPremio_id" class="text medium" maxlength="50"/>
		</div><br/>
		
		<div>
			<fmt:message key="common.codigo"/><br/>
			<input id="txtCodigoPremio_id" class="text medium" maxlength="14"/>
		</div><br/>
		
		<div>
			<fmt:message key="common.maneja.stock"/><br/>
			<select id="stManejaStock" name="stManejaStock" class="text mediumlarge">
				<option value="-1"><fmt:message key="label.itemdefault"/></option>
				<option value="PC"><fmt:message key="common.maneja.stock.punto.canje"/></option>
				<option value="AP"><fmt:message key="common.maneja.stock.almacen.principal"/></option>
				<option value="NM"><fmt:message key="common.no.maneja.stock"/></option>
			</select>
		</div><br/>
		
		<div>
			<fmt:message key="common.maneja.serie"/><br/>
	        <select class="text medium" id="stManejaSerie" >
	        	<option value="-1"><fmt:message key="label.itemdefault"/></option>
				<option value="Y"><fmt:message key="common.yes"/></option>
				<option value="N"><fmt:message key="common.no"/></option>
	       	</select>
		</div><br/>
		
		<div>
			<input type="button" onclick="buscarPremio()" value="<fmt:message key="button.search"/>"/>
		</div>	
	</fieldset><br/><br/>

	<table cellpadding="0" class="table" cellspacing="0" style="width: 900px">
		<thead> 
			<tr> 
	            <th scope="col"><fmt:message key="common.premio"/></th>
	            <th scope="col"><fmt:message key="common.codigo.premio"/></th>
	            <th scope="col"><fmt:message key="common.codigo.articulo"/></th>
	            <th scope="col"><fmt:message key="common.categoria"/></th>
	            <th scope="col"><fmt:message key="common.catalogo"/></th>
	            <th scope="col"><fmt:message key="common.unidad.medida"/></th>
	            <th scope="col"><fmt:message key="common.puntos"/></th>
	            <th scope="col"><fmt:message key="common.dinero"/></th>
	            <th scope="col"><fmt:message key="common.maneja.tipoarticulo"/>?</th>            
	            <th scope="col"><fmt:message key="common.stock.catalogo.estacion"/></th>            
	            <th scope="col"><fmt:message key="common.stock.catalogo"/></th>		
			</tr>
		</thead>
		<tbody id="busquedapremiobody">
			<tr id="pattern" style="display:none;">
				<td><span id="tablePremio"></span></td>
				<td><span id="tableCodigoPremio"></span></td>	
				<td><span id="tableCodigoArticulo"></span></td>
				<td><span id="tableCategoria"></span></td>
				<td><span id="tableCatalogo"></span></td>
				<td><span id="tableUnidadMedida"></span></td>
				<td><span id="tablePuntos"></span></td>						
				<td><span id="tableDinero"></span></td>
				<td><span id="tableManejaStock"></span></td>
				<td><span id="tableStockCatalogoEstacion"></span></td>
				<td><span id="tableStockCatalogo"></span></td>
			</tr>
			<c:forEach var="bnpremio" items="${listapremios}" varStatus="status">	
				<c:choose>
					  <c:when test="${status.index % 2 == 0}"><tr class="odd" ></c:when>
					  <c:otherwise><tr class="even" ></c:otherwise>
				</c:choose>
				
				<td><a href="javascript:void(0)" onClick="Modalbox.hide({beforeHide: function(){					
						$('coCodigoPremioID').value  = '${bnpremio.coCodigoPremio}'}})">					
	                    ${bnpremio.deArticulo}
	                </a></td>
				<td>${bnpremio.coCodigoPremio}</td>
				<td>${bnpremio.coCodigoArticulo}</td>
				<td>${bnpremio.deCategoria}</td>
				<td>${bnpremio.deCatalogo}</td>
				<td>${bnpremio.deUnidadMedida}</td>
				<td>${bnpremio.vaPuntosRequeridos}</td>
				<td>${bnpremio.vaMontoRequerido}</td>
				
				<td><c:choose>
	                		<c:when test="${bnpremio.stManejaStockPuntoCanje == 'Y'}">
	                			<fmt:message key='common.maneja.stock.punto.canje'/>
	                		</c:when>
	                		<c:when test="${bnpremio.stManejaStockAlmPrincipal == 'Y'}">
	                			<fmt:message key='common.maneja.stock.almacen.principal'/>
	                		</c:when>                		
	                		<c:when test="${bnpremio.stNoManejaStock == 'Y'}">
	                			<fmt:message key='common.no.maneja.stock'/>
	                		</c:when>
	               
	                </c:choose></td>
				
				<td><c:choose>			
							<c:when test="${bnpremio.vaStockCatalogoEstacion == null}">
	                			<fmt:message key='label.itemdefault'/>
	                		</c:when>
	                		<c:otherwise>
	                			${bnpremio.vaStockCatalogoEstacion}
	                		</c:otherwise>			
				</c:choose></td>
				<td>${bnpremio.vaStockCatalogo}</td>
				
				</tr>
	        </c:forEach>				
		</tbody>
	</table>

<input type="hidden" id="hdnCoAlmacen" value="${coalmacen}"/>
</form:form>